<?php include 'conf/base.php';?>

<?php $title = gettext("Publicar Anuncio Gratis"). " " .CIUDAD. " | ". gettext("Publicar Anuncio Clasificado Gratis"). " ". CIUDAD. " | ". gettext("Anuncios Locales")?>
<?php $descripcion = gettext("Publicar Anuncio Clasificado Compra Venta, Servicios, Turismo, Inmuebles, Vehiculos, etc")?>
<?php $keywords = gettext("Publicar Anuncio Clasificado Compra Venta, Servicios, Turismo, Inmuebles, Vehiculos, etc")?>

<?php include 'template_header_subdominios.php'?>
<?php include 'template_nav_bar_subdominios.php';?>
<?php include 'template/recurso_plupload.php'?>

<?php 
if(logged_in()){
   
   if (isset($_GET['id'])){
   	
   	$publicacion_valores = get_valores_publicacion($_GET['id'],  array("usuario_id","completa"));
   	
   	if($publicacion_valores['usuario_id']==$_SESSION['usuario_id']){
   
?>

<div class="container">
    <div class="row">       
        <div class="col-md-9"> 

   <div id='publicar_contenido_izq' class='span9'>

	<h2 class="right-line"><?php echo gettext("Agregar Imagenes")?></h2>

	<br>
	<div class="alert alert-info">
		<p>1 - <?php echo gettext("Haga clic en seleccionar imágenes y seleccione las imágenes para su anuncio (máximo 5 imágenes)")?></p>
		<p>2 - <?php echo gettext("Haga clic en subir imágenes")?></p>		
	</div>
	
	<div id="container">
		<div id="filelist"><p><?php echo gettext("Su navegador no tiene soporte Flash, Silverlight, Gears, BrowserPlus o HTML5")?>.</p></div>
		<br /> <a id="pickfiles" href="javascript:;">[<?php echo gettext("Seleccionar Imágenes")?>]</a> <a
			id="uploadfiles" href="javascript:;">[<?php echo gettext("Subir Imágenes")?>]</a>
	</div>	
	
	<input type="hidden" id='publicacion_id' name='publicacion_id' value="<?php echo $_GET['id'];?>"/>
	<br>

	<?php 
	$publicacion = get_valores_publicacion($_GET['id'], array('titulo'));
	$publicacionURL = getPublicacionPath($_GET['id']);
		
		echo "
		       <span>".gettext("Link a su anuncio").": </span> <a href='$publicacionURL'>$publicacion[titulo]</a>
			";
	?>
	<br>
	<br>
	
	<h2 class="right-line"><?php echo gettext("Eliminar Imagenes")?></h2>
	
	<div class="row"> 

     <?php
	     $result=mysql_query("SELECT count(*) as cantidad FROM imagenes WHERE publicacion_id=".$_GET['id']);
	     $data=mysql_fetch_assoc($result);
     
	     if ($data['cantidad'] == 0){
	     	echo "<div class='alert alert-info'>".gettext("El anuncio no posse imágenes")."</div>";	   
	     }
	     
          $sql = "SELECT * FROM imagenes WHERE publicacion_id=".$_GET['id'];          
          $result = mysql_query($sql);
          
            while ($imagen = mysql_fetch_array($result)){
              $publicacion_id = $imagen['publicacion_id'];
              $imagen_path = "http://".DOMINIO_BASE_COMPLETO."/uploads/thumbs/$imagen[filename].$imagen[ext]";
             
                   echo "<div id='div$imagen[imagen_id]' class='col-md-3' style='margin-top: 50px'>
                          
                              <img src='$imagen_path'/>                             
                              <p><input id='$imagen[imagen_id]' class='eliminar-imagen-submit btn btn-ar btn-warning' type='submit' value='".gettext("Eliminar")."'/></p>
                        </div>";
            }   

           
      ?>
       
     </div> <!-- row -->
	

	
<script type="text/javascript">

				// Custom example logic
			function $ob(id) {
				return document.getElementById(id);	
			}

			
			
			var uploader = new plupload.Uploader({

				<?php 		
				
				$user_agent = $_SERVER['HTTP_USER_AGENT'];
				
				if (preg_match('/MSIE/i', $user_agent)) {
					echo "runtimes : 'html4',";
				} else {
					echo "runtimes : 'gears,html5,flash,silverlight,browserplus,html4',";
				};
				
				?>	
									
				browse_button : 'pickfiles',
				container: 'container',
				max_file_size : '10mb',			
				chunk_size : '512kb',					
				unique_names : true,	
				url : '../../upload.php',
				flash_swf_url : '../../plupload/js/plupload.flash.swf',
				silverlight_xap_url : '../../plupload/js/plupload.silverlight.xap',
				filters : [
					{title : "Image files", extensions : "jpg,gif,png"}	
				]
			});
			
			uploader.bind('Init', function(up, params) {
				$ob('filelist').innerHTML = "<div>Current runtime: " + params.runtime + "</div>";
			});
			
			uploader.bind('FilesAdded', function(up, files) {
				for (var i in files) {					
					$ob('filelist').innerHTML += '<div class=item_nueva_imagen id="' + files[i].id + '">' + files[i].name + ' (' + plupload.formatSize(files[i].size) + ') <b></b></div>';
				}
			});
			
			uploader.bind('UploadProgress', function(up, file) {
				$ob(file.id).getElementsByTagName('b')[0].innerHTML = '<span>' + file.percent + "%</span>";
			});
			
			$ob('uploadfiles').onclick = function() {
				uploader.start();
				return false;
			};
			
			uploader.init();
</script>


</div>
</div>
</div>
</div>


<?php }
	}
	} else {
	
		$url = get_login_url();
		exit('<meta http-equiv="refresh" content="0; url=' . urldecode($url) . '"/>');
		
	}?>

<?php include 'template_footer_subdominios.php'?>
<?php include 'template_side_bar_subdominios.php';?>

<!-- Scripts -->
<!-- Compiled in vendors.js -->
<!--
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/jquery.cookie.js"></script>
<script src="assets/js/imagesloaded.pkgd.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/bootstrap-switch.min.js"></script>
<script src="assets/js/wow.min.js"></script>
<script src="assets/js/slidebars.min.js"></script>
<script src="assets/js/jquery.bxslider.min.js"></script>
<script src="assets/js/holder.js"></script>
<script src="assets/js/buttons.js"></script>
<script src="assets/js/jquery.mixitup.min.js"></script>
<script src="assets/js/circles.min.js"></script>
<script src="assets/js/masonry.pkgd.min.js"></script>
<script src="assets/js/jquery.matchHeight-min.js"></script>
-->

<script src="http://<?php echo DOMINIO_BASE_COMPLETO?>/js/vendors.js"></script>
<script src="http://<?php echo DOMINIO_BASE_COMPLETO?>/js/funcionesjs.js"></script>

<!-- Syntaxhighlighter -->
<script src="http://<?php echo DOMINIO_BASE_COMPLETO?>/js/syntaxhighlighter/shCore.js"></script>
<script src="http://<?php echo DOMINIO_BASE_COMPLETO?>/js/syntaxhighlighter/shBrushXml.js"></script>
<script src="http://<?php echo DOMINIO_BASE_COMPLETO?>/js/syntaxhighlighter/shBrushJScript.js"></script>

<script src="http://<?php echo DOMINIO_BASE_COMPLETO?>/js/app.js"></script>
<script src="http://<?php echo DOMINIO_BASE_COMPLETO?>/js/index.js"></script>

</body>

</html>

